package kosta.model.board;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class TechTipBoardDaoImpl implements TechTipBoardDao{
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	/**
	 * 리스트보기
	 */
	@Override
	public List<BoardVO> getListBoard() throws Exception {
		return sqlSessionTemplate.selectList("board.getListBoard");
	}
	/**
	 * 상세보기
	 */
	@Override
	public BoardVO findByNo(int no) throws Exception {
		return sqlSessionTemplate.selectOne("board.findByNo",no);
	}
	/**
	 * 게시판 추가 
	 */
	@Override
	public int insertBoard(BoardVO bvo) throws Exception {
		return sqlSessionTemplate.insert("board.insertBoard",bvo);
	}
	/**
	 * 게시판 삭제
	 */
	@Override
	public void deleteBoard(int no) throws Exception {
		System.out.println(no+"daoImpl------------");
		sqlSessionTemplate.delete("board.deleteBoard",no);
	}
	/**
	 * 수정하기
	 */
	@Override
	public int updateBoard(BoardVO bvo) throws Exception {
		return sqlSessionTemplate.update("board.updateBoard",bvo);
	}
	/**
	 * id로 검색
	 */
	@Override
	public List<BoardVO> findById(String id) throws Exception {
		return sqlSessionTemplate.selectList("board.findById",id);
	}
	/**
	 * title로 검색
	 */
	@Override
	public List<BoardVO> findByTitle(String title) throws Exception {
		return sqlSessionTemplate.selectList("board.findByTitle",title);
	}
	/**
	 * category로 검색
	 */
	@Override
	public List<BoardVO> findByCategory(String category) throws Exception {
		return sqlSessionTemplate.selectList("board.findByCategory",category);
	}
	/**
	 * 조회수증가
	 */
	@Override
	public int updateCount(int no) throws Exception {
		return sqlSessionTemplate.update("board.updateCount",no);
	}
	/**
	 * 전체 게시물 수 
	 */
	@Override
	public int totalContent() throws Exception {
		return sqlSessionTemplate.selectOne("board.totalContent");
	}
	

}
